package com.bst.bsj.bops.web.biz.impl;

import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bst.bsj.bops.web.biz.SeedlingCompanyService;
import com.bst.bsj.common.dal.daointerface.SeedlingCompanyDAO;
import com.bst.bsj.common.dal.dataobject.SeedlingCompany;
import com.homewaimai.common.lang.Paginator;
import com.homewaimai.common.lang.Result;
import com.homewaimai.common.lang.ResultSupport;

@Service("seedlingCompanyService")
public class SeedlingCompanyServiceImpl implements SeedlingCompanyService {

  private static final Log logger = LogFactory.getLog(SeedlingCompanyServiceImpl.class);

  @Autowired
  private SeedlingCompanyDAO seedlingCompanyDAO;

  @Override
  public Result query(Map paramMap) {
    Result result = new ResultSupport(false);

    Long offset = (Long) paramMap.get("offset");
    Long length = (Long) paramMap.get("length");
    Integer page = (Integer) paramMap.get("page");
    Long total = seedlingCompanyDAO.getCounts(paramMap);
    List<SeedlingCompany> seedlingCompanyList = seedlingCompanyDAO.selectAll(paramMap, offset, length);

    // 创建一个分页器(leng.intValue：每页多少条)
    Paginator paginator = new Paginator(length.intValue());
    // 设置总项数
    paginator.setItems(total == null ? 0 : total.intValue());
    // 设置当前页
    paginator.setPage(page);
    result.getModels().put("paginator", paginator);
    result.getModels().put("seedlingCompanyList", seedlingCompanyList);

    result.setSuccess(true);
    return result;
  }

  @Override
  public SeedlingCompany getSeedlingCompany(Long id) {
    return seedlingCompanyDAO.getSeedlingCompany(id);
  }

  @Override
  public int update(SeedlingCompany seedlingCompany) {
    // TODO Auto-generated method stub
    int lid = 0;
    try {

      lid = seedlingCompanyDAO.update(seedlingCompany);
    } catch (Exception e) {
      logger.error("SeedlingCompanyServiceImpl.update(banner) error!", e);
    }
    return lid;
    
  }

  @Override
  public List<Map<String,Object>> queryAuthNum(Map<String, Object> paramsMap ) {

    return seedlingCompanyDAO.queryAuthNum(paramsMap);
  }

  @Override
  public Long queryCount(Map<String, Object> paramMap) {
     return seedlingCompanyDAO.getCounts(paramMap);
  }

  @Override
  public SeedlingCompany getByParams(Map<String, Object> paramsMap) {
    return seedlingCompanyDAO.getByParams(paramsMap);
  }

  @Override
  public void deleteByParams(Map<String, Object> paramsMap) {
     seedlingCompanyDAO.deleteByParams(paramsMap);
  }

 

}
